using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using NHibernate.Data.Managers;
using NHibernate.Data.Models;
using NHibernate.Data.Base;

namespace NHibernate.Data.UnitTests
{
	[TestFixture]
    public partial class ReWineStyleTests : UNuitTestBase
    {
        protected IReWineStyleManager manager;
		
		public ReWineStyleTests()
        {
            manager = managerFactory.GetReWineStyleManager();
        }
		
		protected ReWineStyle CreateNewReWineStyle()
		{
			ReWineStyle entity = new ReWineStyle();
			
			entity.Style = default(Int64);
			entity.Wine = default(Int64);
			
			
			return entity;
		}
		protected ReWineStyle GetFirstReWineStyle()
        {
            IList<ReWineStyle> entityList = manager.GetAll(1);
            if (entityList.Count == 0)
                Assert.Fail("All tables must have at least one row for unit tests to succeed.");
            return entityList[0];
        }
		
		[Test]
        public void Create()
        {
            try
            {
				ReWineStyle entity = CreateNewReWineStyle();
				
                object result = manager.Save(entity);

                Assert.IsNotNull(result);
            }
            catch(Exception ex)
            {
                Assert.Fail(ex.ToString());
            }
        }
        [Test]
        public void Read()
        {
            try
            {
                ReWineStyle entityA = CreateNewReWineStyle();
				manager.Save(entityA);

                ReWineStyle entityB = manager.GetById(entityA.Id);

                Assert.AreEqual(entityA, entityB);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.ToString());
            }
        }
        [Test]
        public void Delete()
        {
            try
            {
                ReWineStyle entity = GetFirstReWineStyle();
				
                manager.Delete(entity);

                entity = manager.GetById(entity.Id);
                Assert.IsNull(entity);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.ToString());
            }
        }
	}
}